package com.aaa.outbound.service.impl;


import com.aaa.entity.outbound.Review;
import com.aaa.entity.outbound.ReviewDetail;
import com.aaa.outbound.mapper.ReviewMapper;
import com.aaa.outbound.service.ReviewService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wjf
 * @since 2020-11-27
 */
@Service
public class ReviewServiceImpl extends ServiceImpl<ReviewMapper, Review> implements ReviewService {
    @Autowired
    private ReviewMapper reviewMapper;

    @Override
    public Page<Review> searchReview(Integer page, Integer limit, Review review) {
        Page<Review> pageinfo=new Page<>(page,limit);
        String outorderno=review.getOutorderno();
        String state=review.getState();
        QueryWrapper<Review> queryWrapper=new QueryWrapper<>();
        if(StringUtils.isNotEmpty(outorderno)){
            queryWrapper.like("outorderno",outorderno);
        }
        if(StringUtils.isNotEmpty(state)){
            queryWrapper.like("state",state);
        }
        this.reviewMapper.selectPage(pageinfo,queryWrapper);
        return pageinfo;
    }

    @Override
    public List<ReviewDetail> selectReviewDetailByPid(Long pid) {
        return reviewMapper.selectReviewDetailByPid(pid);
    }

    /*@Override
    public Integer addReview(Review review) {
        Date now = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        review.setId(null);
        review.setOutorderno("PN"+dateFormat.format(now));
        return pickMapper.insert(pick);
    }*/
}
